<template>
  <div>
      <public-header></public-header>
      <div >
          <h2>{{newsInfo.title}}</h2>
          <div><span>作者：{{newsInfo.user ? newsInfo.user.name : '管理员'}}</span>  |  <span>时间：2018-8-10</span></div>
          <div v-html="newsInfo.info"></div>
          <p>{{newsInfo.time}}</p>
      </div>
      <public-footer></public-footer>
  </div>
</template>

<script>
import PublicHeader from '../Public/PublicHeader'
import PublicFooter from '../Public/PublicFooter'
import axios from '../../http_axios'
export default {
  name: 'NewsDetail',
  data () {
    return {
      newsInfo: {}
    }
  },
  methods: {
    getNewsInfo: function () {
      axios.get('http://www.laravel.com/api/v1/articles/' + this.$route.query.id, {
        headers: {
          'Authorization': 'Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsImp0aSI6IjZhZmJiNzNhZTUyZTczMzJiNTE1OWJkZjliMmZlNWVjNjAzY2ZiNWExZjY0ZTlmMmRkZGMyM2FkN2QwMDc4MjExNjhiMTQ3ODUwYzhhZjhkIn0.eyJhdWQiOiIxIiwianRpIjoiNmFmYmI3M2FlNTJlNzMzMmI1MTU5YmRmOWIyZmU1ZWM2MDNjZmI1YTFmNjRlOWYyZGRkYzIzYWQ3ZDAwNzgyMTE2OGIxNDc4NTBjOGFmOGQiLCJpYXQiOjE1MzUwNzQzODUsIm5iZiI6MTUzNTA3NDM4NSwiZXhwIjoxNTY2NjEwMzg1LCJzdWIiOiIyOSIsInNjb3BlcyI6W119.HboOWdUZD-Ga-POheXXJMRblpuAOTJy4xHo_sb2Ljpbuwzay4BofiAPwF2_rJlMk005n_PlZIlUXy_cXTfBcdVQxP5DtZO0eo_gE8VWP2kXskwlvsfC26BcHFAdKWiUorfT50XPmLbdwWZO637lNOFT8Ux4fV1ArQyCGfsRlO6X1v22oafeEafiCF3jSZ1ZSCgbBpcL_DttAw1LgXM8PMJ_ld9GyvZA60HpHVoSloRrU4nTfXlr6g09Qmw880ziU3NJnbhMG06ZdvvMHEi8_CD-oPIfUyuSyY1qfhKRZnUeV-KAB42v2IbpoOUawcgd2y_KtFdiyu2ljg4uC5jbyM74jvVowU-qzh736vvDtxiuJYSR1td6LF0mf46fZ5kp_EwpTmbT0b4zkD9mMu8ZQQF-9MGzI1jFFTtCb03mfQ2u2Wgr_Rz_8WWxV-WOlTp_VdRBCQ-cBS7C8xaoW8xzXXU-xrw_4rX0lgvQ9pacd5zQ4OzK9HYo9i5gRO_mZsfH_COAwiyPu3k7Z4S8fjX4PypWwKiLv_BvR848zYVyzo1J0M75WwRzQiiC3y1MbwgeATabLX5vhve6oHt7biEZMbzTwFilcHFsYMIbPubMTUU8OSyouXnsdLAIfQ-ihrwliwJErj3PWKdSbGq2bLSx2VDddnArLFEdRhS--y4cLlK8'
        }
      }).then(this.succDetail)
    },
    succDetail (res) {
      let info = res.data
      if (info.code === 200) {
        this.newsInfo = info.data
      }
    }
  },
  watch: {
    '$route': 'getNewsInfo'
  },
  created () {
    this.getNewsInfo()
  },
  mounted () {
    // this.getNewsInfo()
  },
  components: {
    PublicHeader,
    PublicFooter
  }
}
</script>

<style scoped>
</style>
